<!-- 问题类型管理 -->
<template>
  <div class="table">
    <SearchTable v-model:formStatus="formStatus" :selectMap="selectMap" ref="searchTableRef" @handleViewEdit="handleViewEdit" />
    <FormDialog v-model:formStatus="formStatus" :selectMap="selectMap" v-model:form="form" @handleSuccess="handleSuccess" />
  </div>
</template>

<script setup lang="ts" name="commonProblemClass">
import SearchTable from "@/components/configInfo/problemManage/commonProblemClass/SearchTable.vue";
import FormDialog from "@/components/configInfo/problemManage/commonProblemClass/FormDialog.vue";
import type { ViewMode, ViewModeFilter } from "@/types/common";
import type { IFaqCategory } from "@/types/problemManage/faqCategory";
import type { IDictData } from "@/types/dict";
import { useDictData } from "@/hooks/network/useDictData";
/* 表格子组件的引用 */
const searchTableRef = useTemplateRef("searchTableRef");
const formStatus = ref<ViewMode>("none");
const form = reactive<IFaqCategory>({
  id: 0,
  name: "",
  image: "",
  scenario: "",
  sort: 0
});
const selectMap = ref<Array<IDictData>>([]);
/* 点击编辑按钮 */
function handleViewEdit(row: IFaqCategory, code: ViewModeFilter) {
  formStatus.value = code;
  nextTick(() => {
    form.id = row.id;
    form.name = row.name;
    form.image = row.image;
    form.scenario = row.scenario;
    form.sort = row.sort;
  });
}
/* 成功保存或者编辑的回调 */
function handleSuccess() {
  searchTableRef.value?.getTableInfo();
}
let { getDictData } = useDictData();
getDictData("FAQ_SCENARIO", selectMap);
</script>

<style lang="scss" scoped></style>
